﻿<%@ Page Title="collection" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="crm_collection.aspx.cs" Inherits="Sami_SMS_CRM_UI.crm_collection" MaintainScrollPositionOnPostback="true" %>

<%@ Register Src="UserControl/ucPaging.ascx" TagName="ucPaging" TagPrefix="uc1" %>
<asp:Content ID="CSS" runat="server" ContentPlaceHolderID="CssContent">
    <style type="text/css">
        .detail{color: #555555; text-decoration:none;}
        .detail:hover{text-decoration:underline;}
        tr.pagging td {height:20px; padding:0; margin:0; color:#949494;}
        tr.pagging td td{ border:solid 1px #48719D; height:20px; background:#48719D; width:20px; text-align:center;}
        tr.pagging:hover td{background: none;}
        tr.pagging a{ background:#C3C3C3; height:20px; line-height:20px; padding:0 8px; text-decoration: none; color:#949494;display:inline-block;}
        tr.pagging a:hover { border-color:#48719D; background:#48719D; color:#fff; }
    </style>
</asp:Content>
<asp:Content ID="Script" runat="server" ContentPlaceHolderID="ScriptContent">
    <script type="text/javascript">
        $(document).ready(function () {
            RegisterDialog();
        });

        function dialog() {
            OpenDialog("dialog1",950);
        }

        function dialog2() {
            $("#dialog2").dialog({
                autoOpen: false,
                modal: true,
                width: 890,
                height: 700,
                buttons:{
                     Cancel: function() {
                        $( this ).dialog( "close" );
                    }
                }
            });
            $("#dialog2").dialog('open');
            return false;
        }
        function ClearData() {
            $("[id$=txtCollectionName]").val("");
            $("[id$=txtSelectClause]").val("");
            $("[id$=txtFromClause]").val("");
            $("[id$=txtWhereClause]").val("");
            $("[id$=txtDescription]").val("");
        }
    </script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <div class="box">
        <div class="box-title clearfix">
            <div class="fl">
                List of CRM_Collection
            </div>
            <div class="fr">
                <asp:ImageButton ID="btnAddNew" runat="server" ImageUrl="~/img/icons/ws/ic_plus.png"
                    ToolTip="Add New" OnClick="btnAddNew_Click" />
            </div>
        </div>
        <div class="box-content">
            <div class="clearfix" style="height: 32px">
                <div class="fl">
                    Show
                    <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged">
                        <asp:ListItem Value="5">5</asp:ListItem>
                        <asp:ListItem Value="10">10</asp:ListItem>
                        <asp:ListItem Value="20">20</asp:ListItem>
                        <asp:ListItem Value="50" Selected="True">50</asp:ListItem>
                        <asp:ListItem Value="100">100</asp:ListItem>
                        <asp:ListItem Value="150">150</asp:ListItem>
                        <asp:ListItem Value="200">200</asp:ListItem>
                    </asp:DropDownList> / 
                    <asp:Literal ID="ltrTotalRow" runat="server" Text="0" /> 
                    entries
                </div>
                <div class="fr">
                    <uc1:ucPaging ID="pagingtop" runat="server" />
                </div>
            </div>
            <div class="clearfix">
                <table class="table" style="width:100%">
                    <thead>
                        <tr>
                            <th style="width:35px">No</th>
                            <th>Collection Name</th>
                            <th>Collection type</th>
                            <th>Description</th>
                            <th>Enable</th>
                            <th style="width:80px;">Control</th>
                        </tr>
                    </thead>
                    <tbody>
                        <asp:Repeater ID="rptTable" runat="server" onitemcommand="rptTable_ItemCommand">
                            <ItemTemplate>
                                <tr>
                                    <td style="text-align: center">
                                        <%#(Container.ItemIndex +1) + (pagingtop.CurrentPage - 1) * pagingtop.PageSize %>
                                    </td>
                                    <td>
                                        <asp:LinkButton Text='<%#Eval("collection_name")%>' CommandName="ViewDetail" CommandArgument='<%#Eval("collection_id")%>' runat="server" CssClass="detail" />
                                    </td>
                                    <td><%#Eval("collection_type")%></td>
                                    <td><%#Eval("description")%></td>
                                    <td><%#Eval("enabled")%></td>
                                    <td style="text-align:center">
                                        <asp:LinkButton Text="Edit" runat="server" CommandName="Edited"
                                            CommandArgument='<%#Eval("collection_id")%>' />
                                            &nbsp;
                                        <asp:LinkButton  Text="Delete" runat="server" CommandName="Deleted"
                                            CommandArgument='<%#Eval("collection_id")%>' OnClientClick="return confirm('Are you sure delete?');" />
                                    </td>
                                </tr>
                            </ItemTemplate>
                        </asp:Repeater>
                    </tbody>
                </table>
                <div class="fr">
                    <uc1:ucPaging ID="pagingbottom" runat="server" />
                </div>
            </div>
        </div>
    </div>
    <div class="dialog-form" id="dialog1" style="margin: auto; width: 480px;" title="CRM Collection">
        <div>
            <asp:HiddenField ID="hdfAction" runat="server" />
            <asp:HiddenField ID="hdfId" runat="server" />
            <p>
                <span>Collection Name</span>
                <asp:TextBox ID="txtCollectionName" runat="server" TextMode="MultiLine" />
            </p>
            <p>
                <span>Collection type</span>
                <asp:DropDownList ID="ddlCollectionType" runat="server" AutoPostBack="true"
                    onselectedindexchanged="ddlCollectionType_SelectedIndexChanged" >
                    <asp:ListItem Value="sqlcommand">sqlcommand</asp:ListItem>    
                    <asp:ListItem Value="directly">directly</asp:ListItem>    
                </asp:DropDownList>
            </p>
            <asp:Panel runat="server" ID="pnsqlcommand" style="padding: 5px 0px">
                <span>Colection Value</span>
                <table style="width:100%;">
                    <tr>
                        <td>select: </td>
                        <td><asp:TextBox ID="txtSelectClause" runat="server" TextMode="MultiLine" /></td>
                    </tr>
                    <tr>
                        <td>from: </td>
                        <td><asp:TextBox ID="txtFromClause" runat="server" TextMode="MultiLine" /></td>
                    </tr>
                    <tr>
                        <td>where: </td>
                        <td><asp:TextBox id="txtWhereClause" runat="server" TextMode="MultiLine" /></td>
                    </tr>
                </table>
            </asp:Panel>
            <asp:Panel runat="server" ID="pndirectly" style="padding: 5px 0px">
                <asp:FileUpload ID="uplSourceFile" runat="server" />
                <br />
                <span>service</span>
                <asp:DropDownList ID="ddlService" runat="server" />
                <asp:Button ID="btnUpLoad" runat="server" Text="UpLoad" 
                    onclick="btnUpLoad_Click" />
            </asp:Panel>
            <p>
                <span>Description</span>
                <asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" />
            </p>
            <p>
                <span>Enable</span>
                <asp:DropDownList ID="ddlStatus" runat="server">
                    <asp:ListItem Value="true">True</asp:ListItem>
                    <asp:ListItem Value="false">False</asp:ListItem>
                </asp:DropDownList>
            </p>
            <div style="text-align: right; margin-top: 5px; padding-top: 5px; border-top: 1px solid #C3C3C3;">
                <asp:Button ID="btnOK" runat="server" Text="OK" CssClass="ui-button" OnClick="btnOK_Click" />
                <input type="button" value="Cancel" onclick='ClearData(); $("#dialog1").dialog("close");'
                    class="ui-button" />
            </div>
        </div>
    </div>
    <div class="dialog-form" id="dialog2" style="margin: auto; width: 480px;" title="Subscribers">
        <asp:UpdatePanel ID="udpn" runat="server">
            <ContentTemplate>
                <span>Collection value:</span>
                <asp:TextBox ID="txtCollectionValue" runat="server" TextMode="MultiLine" Rows="4" Width="850px"/>
                <asp:Button ID="btnTestValue" runat="server" Text="Test" CssClass="ui-button" onclick="btnTestValue_Click" />
                <asp:Label ID="txtError" runat="server" EnableViewState="false"></asp:Label><br /><br />
                <asp:GridView CssClass="table" ID="grvTestCollection" runat="server" AutoGenerateColumns="true" EnableViewState="false"
                    AllowPaging="true" PageSize="15" onpageindexchanging="grvTestCollection_PageIndexChanging" Width="850px">
                    <PagerStyle CssClass="pagging" HorizontalAlign="Right"/>
                    <PagerSettings PageButtonCount="6" />
                </asp:GridView>                
                <span>Subscriber list:</span>
              <asp:GridView CssClass="table" runat="server" ID="grvDetail" AutoGenerateColumns="false"
                AllowPaging="true" PageSize="15" onpageindexchanging="grvDetail_PageIndexChanging" Width="850px">
                <PagerStyle CssClass="pagging" HorizontalAlign="Right"/>
                <PagerSettings PageButtonCount="6" />
                <Columns>
                    <asp:TemplateField HeaderText="No">
                        <ItemStyle Width="35px" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <%# Container.DataItemIndex + 1 %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderText="Subscriber" DataField="subscriber" />
                    <asp:BoundField HeaderText="full_name" DataField="full_name" />
                    <asp:BoundField HeaderText="date_of_birth" DataField="date_of_birth" />
                    <asp:BoundField HeaderText="description" DataField="note" HeaderStyle-Width="180px"/>
                    <asp:BoundField HeaderText="enabled" DataField="enabled" />
                    <asp:BoundField HeaderText="operator_id" DataField="operator_id" />
                    <asp:BoundField HeaderText="gateway_id" DataField="gateway_id" />

                </Columns>
            </asp:GridView>       
            <p style="display: block; margin: 5px; padding: 5px; color: #818181">
                <asp:Label ID="lbTotal" runat="server" />
            </p>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <input type="hidden" id="formId" value="crm_collection" />
</asp:Content>
